package com.evaluation_system.mapper;

import com.evaluation_system.pojo.DTO.ResetPasswordDTO;
import com.evaluation_system.pojo.entity.LoginInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {

    @Select("SELECT * " +
            "FROM `uploader` WHERE username = #{username}")
    LoginInfo uploaderbyusername(String username);

    @Select("SELECT * " +
            "FROM `checker` WHERE username = #{username}")
    LoginInfo checkerbyusername( String username);

    @Select("SELECT * " +
            "FROM `evaluator` WHERE username = #{username}")
    LoginInfo evaluatorbyusername( String username);

    @Select("SELECT * " +
            "FROM `admin` WHERE username = #{username}")
    LoginInfo adminbyusername(String username);
//    @Insert("INSERT INTO `uploader` (username, password) VALUES (#{username}, #{password})")
//    @Options(useGeneratedKeys = true, keyProperty = "id")  // 主键自动生成并注入到对象中
    int updateUploaderPassword(LoginInfo loginInfo);

//    @Insert("INSERT INTO `checker` (username, password) VALUES (#{username}, #{password})")
//    @Options(useGeneratedKeys = true, keyProperty = "id")
    int updateCheckerPassword(LoginInfo loginInfo);

//    @Insert("INSERT INTO `evaluator` (username, password) VALUES (#{username}, #{password})")
//    @Options(useGeneratedKeys = true, keyProperty = "id")
    int updateEvaluatorPassword(LoginInfo loginInfo);

    @Select("SELECT EXISTS (SELECT 1 FROM uploader WHERE username = #{username})")
    boolean uploaderfind(String username);

    @Select("SELECT EXISTS (SELECT 1 FROM checker WHERE username = #{username})")
    boolean checkerfind(String username);

    @Select("SELECT EXISTS (SELECT 1 FROM evaluator WHERE username = #{username})")
    boolean evaluatorfind(String username);

}
